<?php

$client = new swoole_redis;
$options = array(
    'timeout' => 2,
    'password' =>'!@#$981596276',
    'database' => 0,
);

$client->__construct( $options);
$client->connect('120.31.131.231', 6379, function (swoole_redis $client, $result) {
    if ($result === false) {
        echo "connect to redis server failed.\n";
        return;
    }
    $client->set('key', 'swoole', function (swoole_redis $client, $result) {
        var_dump($result);
    });
});